package com.bw.car.model

import com.blankj.utilcode.util.NetworkUtils
import com.bw.car.api.CarPayApiServer
import com.bw.car.entity.AddCarEntity
import com.bw.car.entity.PayNewEntity
import com.bw.car.entity.PaymentEntity
import com.bw.car.entity.StopCarEntityItem
import com.bw.common.entity.BaseRes
import javax.inject.Inject

class CarPayRepository @Inject constructor(private val apiServer:CarPayApiServer) {
    //省份简称
    suspend fun loadCarPayData():BaseRes<List<PaymentEntity>>{
        return if (NetworkUtils.isAvailable()){
            apiServer.loadCarPayData()
        }else{
            BaseRes(400, emptyList(),"当前没有网络！")
        }
    }

    //添加车辆
    suspend fun loadAddCarData(carEntity:AddCarEntity):BaseRes<AddCarEntity>{
        return apiServer.loadAddCar(carEntity)
    }
    //获取所有停车记录
    suspend fun loadStopCarRecord():BaseRes<List<StopCarEntityItem>>{
        return apiServer.loadStopCarRecord()
    }
    //立即支付
    suspend fun loadPaymentData(payNew:PayNewEntity):BaseRes<PayNewEntity>{
        return apiServer.loadPayment(payNew)
    }
}